package com.qianniu.napi.admin.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.google.common.base.Strings;
import com.qianniu.napi.admin.entity.Merchant;
import com.qianniu.napi.admin.entity.MerchantApp;
import com.qianniu.napi.admin.mapper.MerchantAppMapper;
import com.qianniu.napi.admin.mapper.MerchantMapper;
import com.qianniu.napi.admin.mapper.OrderGoodsMapper;
import com.qianniu.napi.admin.service.IMerchantService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.qianniu.napi.common.config.Constants;
import com.qianniu.napi.common.util.ObjectUtil;
import com.qianniu.napi.common.util.SpringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 商家 服务实现类
 * </p>
 *
 * @author chenxuebin
 * @since 2018-06-17
 */
@Service
public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> implements IMerchantService {


    @Autowired
    private MerchantMapper merchantMapper;

    @Autowired
    private MerchantAppMapper merchantAppMapper;

    public MerchantApp getCurrentMerchant(long mid,String appid){

        Wrapper<MerchantApp> wrapper = new EntityWrapper<MerchantApp>().eq("mid",mid);

        if(!Strings.isNullOrEmpty(appid)){
            wrapper.eq("appid",appid);
        }else{
            wrapper.eq("is_master",1);
        }
        List<MerchantApp> list = merchantAppMapper.selectList(wrapper);
        MerchantApp merchantApp = list==null||list.size()==0?null:list.get(0);
        return merchantApp;
    }

}
